<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMatchGuestsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('match_guests', function(Blueprint $table)
		{
			$table->engine = 'InnoDB';

			$table->increments('id');

			$table->unsignedInteger('matchId');
			$table->unsignedInteger('userId');
			$table->timestamps();
		});

		Schema::table('match_guests', function($table)
		{
		    $table->foreign('matchId')->references('id')->on('match_data')->onDelete('cascade');
			$table->foreign('userId')->references('id')->on('user')->onDelete('cascade');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::dropIfExists('match-guests');
	}

}
